﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace problema3
{
    class Program
    {
        static void Main(string[] args)
        {
            int raspuns=1;
            Console.WriteLine("1.Trimite query catre baza de date\n2.Iesire");
            raspuns=Int32.Parse(Console.ReadLine());
            while (raspuns == 1)
            {
                Console.WriteLine("Numele bazei de date:");
                string dbname = Console.ReadLine();
                Console.WriteLine("Tip query:\n\t1.SQLQuery\n\t2.ConnectionQuery");
                int tip = Int32.Parse(Console.ReadLine());
                string tabel,user,pwd;
                if (tip == 1)
                {
                    Console.WriteLine("Nume tabel:");
                    tabel = Console.ReadLine();
                    SQLQuery query = new SQLQuery();
                    query.setDabaseName(dbname);
                    query.setTableName(tabel);

                    RemoteConnection rc = new RemoteConnection();
                    rc.conn_pool = ConnectionPool.getInstance();
                    rc.databasename = dbname;
                    Console.WriteLine(rc.SendQuery(query));

                    rc.afiseaza_conexiuni();

                }
                else if (tip == 2)
                {
                    Console.WriteLine("User:");
                    user = Console.ReadLine();
                    Console.WriteLine("Parola:");
                    pwd = Console.ReadLine();
                    ConnectionQuery cquery = new ConnectionQuery();
                    cquery.setDabaseName(dbname);
                    cquery.setPassword(pwd);
                    cquery.setUserName(user);

                    RemoteConnection rc = new RemoteConnection();
                    rc.conn_pool = ConnectionPool.getInstance();
                    rc.databasename = dbname;
                    Console.WriteLine(rc.SendQuery(cquery));

                    rc.afiseaza_conexiuni();
                }

                Console.WriteLine("1.Trimite query catre baza de date\n2.Iesire");
                raspuns = Int32.Parse(Console.ReadLine());

            }
        }
    }
}
